<template>
  <div>
    <div class="newDetail box">
      <h5>{{newContent.title}}</h5>
      <p>发表时间：{{getTime}}<span>点击次数：{{newContent.click}}</span></p>
    </div>
    <div v-html="newContent.content" class="content"></div>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      newContent: {
        add_time:''
      }
    };
  },
  created() {
    this.getNew();
  },
  methods: {
    async getNew() {
      // console.log(this.id);

      const { data: res } = await this.$axios.get(
        `/api/getnew/${this.goodsId}`
      );
      //   console.log(res.message);
      this.newContent = res.message[0];
      console.log(this.newContent);
      
    }
  },
  computed: {
    ...mapState(["id"]),
    goodsId() {
      return this.$route.params.id;
    },
    getTime(){
      return this.newContent.add_time.slice(0,10)
    }
  }
};
</script>
<style scoped lang="less">
.newDetail{
  margin: 40px 10px 0 10px;
  height: 60px;
  color: #1989fa;
  border-bottom: 1px solid #ccc;
  h5{
    text-align: center;
    line-height: 30px;
  }
  p{
    line-height: 10px;
    font-size: 12px;
  }
  span{
    float: right;
  }
}
.content{
  padding: 0 10px;
  color: #535353;
  padding-bottom: 50px;
}
</style>